# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=dscanner
pkgver=0.9.0
pkgrel=2
pkgdesc="Swiss-army knife for D source code"
url="https://github.com/dlang-community/D-Scanner"
arch="x86_64 aarch64" # ldc
license="BSL-1.0"
makedepends="dcontainers-dev dsymbol-dev libdparse-dev stdx-allocator-dev
	libddoc-dev inifiled-dev ldc ldc-runtime bash"
options="!check" # need static libs
source="https://github.com/dlang-community/D-Scanner/archive/v$pkgver/dscanner-$pkgver.tar.gz"
builddir="$srcdir/D-Scanner-$pkgver"

prepare() {
	default_prepare

	# Work around makefile calling git describe --tags
	cat > ver.sh  <<EOF
#!/bin/sh
echo "$pkgver"
EOF
	chmod +x ver.sh
}

build() {
	# Use system libraries
	export DFLAGS="$DFLAGS -Os $(pkg-config --cflags dcontainers dsymbol dparse stdx-allocator) -I/usr/include/d/inifiled/inifiled -I/usr/include/d/ddoc $(pkg-config --libs dcontainers dsymbol dparse stdx-allocator | sed -r 's|-l([A-Za-z]+)|-L=-l\1|g') -L=-lddoc -L=-linifiled"
	make DC=ldc2 GIT="$builddir"/ver.sh ldc
}

package() {
	install -Dm755 bin/dscanner "$pkgdir"/usr/bin/dscanner
}

sha512sums="4d2564590a48231d4c1dd8a4126d5b640bd83e90e7189ceac33c2727f981f690e94079411f7f3cbb727be780069cebeacdd38fa6b78b4516cec4e23a8eb12aff  dscanner-0.9.0.tar.gz"
